package com.qf.controller;

import com.netflix.discovery.converters.Auto;
import com.qf.Resp.BaseResp;
import com.qf.loanapplication.Loanapplication;
import com.qf.operators.Operators;
import com.qf.service.OperatorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class OperatorsController {

    @Autowired
    OperatorsService operatorsService;

    /*(两表)查询所有的申请人*/
    @RequestMapping("/selectAllByProposer")
    public BaseResp selectAllByProposer() {
        List<Operators> operators = operatorsService.selectAllOperators();
        BaseResp baseResp = new BaseResp();
        baseResp.setMessage(operators);
        baseResp.setCode(10001l);
        System.out.println("baseResp = " + baseResp);
        return baseResp;
    }

    /*(两表进行查询)对申请人的申请表进行id进行查看*/
    @RequestMapping("/selectAllByProposerId")
    public BaseResp selectAllByProposerId(@RequestBody Map map) {
        Integer id = (Integer) map.get("id");
        Operators operators = operatorsService.selectOneProposerById(id);
        BaseResp baseResp = new BaseResp();
        baseResp.setMessage(operators);
        baseResp.setCode(10003l);
        System.out.println("baseResp = " + baseResp);
        return baseResp;
    }

    @RequestMapping("/repayment")
    public void repayment(@RequestParam("allMoney") Double allMoney){
        operatorsService.repayment(allMoney);
        System.out.println("还款成功");
    }

}
